<template>
    <rx-dialog @handOk="submitForm" @cancel="cancel" order="buttom" btnalign="center">
        <rx-fit>
            <div style="height:100%;width:100%;padding:20px;">
                <a-form-model ref="form" :model="form" :rules="rules">
                    <a-form-model-item :label="i18n('delPage.authId','授权用户')" :labelCol="labelCol1" :wrapperCol="wrapperCol1">
                        <rx-user-info :userId="authId" :showDeptName="true" />
                    </a-form-model-item>
                    <a-form-model-item :label="i18n('delPage.createTime','授权时间')" :labelCol="labelCol1" :wrapperCol="wrapperCol1">
                        {{createTime}}
                    </a-form-model-item>
                    <a-form-model-item :label="i18n('delPage.desc','备注')" :labelCol="labelCol1" :wrapperCol="wrapperCol1" prop="opinion">
                        <rx-textarea-ext v-model="form.opinion" :auto-size="{'minRows':4}"></rx-textarea-ext>
                    </a-form-model-item>
                </a-form-model>
            </div>
        </rx-fit>
    </rx-dialog>
</template>

<script>
    import {BaseFormModel, RxDialog,Util} from '@lowcode/jpaas-common-lib';
    import BpmInstPermissionApi from "@/api/bpm/core/bpmInstPermission";
    import rxTextareaExt from "../comps/rxTextareaExt";

    export default {
        name: "accessDel",
        props:{
            instId:String,
            id:String,
            authId:String,
            createTime:Date,
            layerid: String,
            lydata: Object,
            destroy:Function
        },
        mixins:[BaseFormModel],
        components:{
            RxDialog,
            rxTextareaExt
        },
        data (){
            return {
                rules: {
                    opinion:[{ required: true, message: this.i18n('delPage.msg.validDesc','请输入备注'), trigger: 'change' }]
                },
                form:{
                    opinion:""
                }
            }
        },
        created(){
            this.init();
        },
        methods:{
            i18n(name,text,key){
                return this.$ti18(name,text,"BpmInstPermissionManagement",key);
            },
            init(){
                this.form.instId=this.instId;
                this.form.permissionId=this.id;
            },
            closeWindow(){
                Util.closeWindow(this,'cancel');
            },
            submitForm(e) {
                var self_ = this;
                this.$refs.form.validate(valid => {
                    if (!valid) {
                        e.loading = false;
                        return;
                    }
                    BpmInstPermissionApi.delPermission(self_.form).then(resp => {
                        e.loading = false;
                        if (resp.success) {
                            Util.closeWindow(self_, "ok");
                        }
                    })
                })
            }
        }
    }
</script>

<style scoped>

</style>